package cpb.module.evaluation.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.ArrayList;

import cpb.module.evaluation.R;

/**
 * Author:Cpb
 * Time  : 2019-08-06
 * Desc  :
 */
public class OptionListAdapter extends BaseQuickAdapter<String,BaseViewHolder> {

    private int selectIndex = -1;

    public OptionListAdapter() {
        super(R.layout.evaluation_item_option, new ArrayList<String>());
    }

    public void updateSelect(int selectIndex) {
        this.selectIndex = selectIndex;
        notifyDataSetChanged();
    }

    public int getSelectIndex() {
        return selectIndex;
    }

    @Override
    protected void convert(BaseViewHolder helper, String item) {
        TextView tvOption = helper.getView(R.id.tv_option);
        tvOption.setText(item);
        tvOption.setSelected(helper.getAdapterPosition() == selectIndex);
    }
}
